package com.fadadianqi.goods.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.goods.dao.PropertiesDAO;
import com.fadadianqi.goods.model.Properties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class PropertiesDAOImpl extends GenericDAOSuport<String, Properties> implements PropertiesDAO {

    @Override
    protected Class<?> getObjectClass() {
        return Properties.class;
    }

    @Override
    protected String getTableName() {
        return "category_properties";
    }

    @Override
    public List<Properties> findByCategoryId(String categoryId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("categoryId", categoryId);
        return super.findByPropertys(map);
    }

    @Override
    public Properties getByCategoryIdAndName(String categoryId, String name) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("categoryId", categoryId);
        map.put("name", name);
        return super.getByPropertys(map);
    }

}
